import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @Author wonghiu
 * @Date 2021/8/8 18:48
 * @Version 1.0.1
 */
public class pdd2 {
    public static void main(String[] args) throws IOException {

        Scanner in = new Scanner(System.in);
        Integer n = Integer.valueOf(in.next());
        for (int i = 0; i < n; i++) {
            int[] ints = new int[3];
            for (int j = 0; j <3 ; j++) {
                ints[j] = in.nextInt();
            }
            int res = countR(ints[0],ints[1],ints[2]);
            System.out.println(res);
        }
    }
    static int countR(int x,int y,int r){
        int count = 0;
        x = Math.abs(x);
        y = Math.abs(y);
        if ((x*x+y*y)==r*r){
            return 3;
        }
        if(r==x){
            count++;
        }else if (r>x){
            count=count+2;
        }
        if(r==y){
            count++;
        }else if (r>y){
            count=count+2;
        }
        return count;
    }

}
